package com.zhang.postgresql.common.model;

import com.baomidou.mybatisplus.core.metadata.OrderItem;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * 示例
 *
 * @author zhangFanJun
 * @date 2022-11-12 11:17
 **/
@Data
@EqualsAndHashCode(callSuper = false)
public class SimpleReqDTO extends KingPageReqDTO implements IDefaultSort, Serializable {

    public static final String DEFAULT_COLUMN_ONE = "applicationDate";


    @Override
    public List<OrderItem> getDefaultSort() {
        OrderItem one = OrderItem.desc(DEFAULT_COLUMN_ONE);
        return Collections.singletonList(one);
    }

    @Override
    public List<OrderItem> getTailSort() {
        return Collections.emptyList();
    }

    /**
     * 时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date creatTime;

    /**
     * 分页查找入参
     */
    private Page page() {
        return PageUtil.getPage(this, this);
    }

    /**
     * 结果返回
     */
    private <T> PageResponseVO<T> result(Page<T> page) {
        return KingPageResult.getResult(page);
    }

}
